import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
  DefaultValuePipe,
  ParseIntPipe,
  UseGuards,
} from '@nestjs/common';
import { MercadoproductService } from 'src/service/mercadoproduct.service';
import { CreateMercadoproductDto } from 'src/dto/create-mercadoproduct.dto';
import { UpdateMercadoproductDto } from 'src/dto/update-mercadoproduct.dto';
import { QueryMercadoproductDto } from 'src/dto/query-mercadoproduct.dto';
import { AdminGuard } from 'src/guards/admin.guard';

@Controller('admin/mercadoproduct')
@UseGuards(AdminGuard)
export class MercadoproductController {
  constructor(private readonly mercadoproductService: MercadoproductService) {}

  @Post()
  create(@Body() createMercadoproductDto: CreateMercadoproductDto) {
    return this.mercadoproductService.create(createMercadoproductDto);
  }

  @Get('likeQuery')
  likeQuery(@Query('likes') likes: string) {
    return this.mercadoproductService.likeQuery(likes);
  }

  @Get()
  query(@Query() query: QueryMercadoproductDto) {
    return this.mercadoproductService.query(query);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.mercadoproductService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateMercadoproductDto: UpdateMercadoproductDto,
  ) {
    return this.mercadoproductService.update(+id, updateMercadoproductDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.mercadoproductService.remove(+id);
  }

  @Post('excelExport')
  excelExport(@Body('id') id: number) {
    return this.mercadoproductService.excelExport(id);
  }
}
